-- 文件路径: ~/.config/nvim/lua/plugins/lsp-enhance.lua
return {
    -- LSP 核心增强
    {
        "neovim/nvim-lspconfig",
        event = "LspAttach",
        dependencies = {
            "glepnir/lspsaga.nvim",
            "folke/trouble.nvim",
            "nvim-tree/nvim-web-devicons"
        },
        opts = {
            -- 基础诊断配置
            diagnostics = {
                virtual_text = { severity = vim.diagnostic.severity.ERROR }, -- 仅显示错误级行内提示
                underline = true,
                signs = true,
                update_in_insert = false
            }
        }
    },

    -- LSP UI 增强 (lspsaga)
    {
        "glepnir/lspsaga.nvim",
        event = "LspAttach",
        config = function()
        require("lspsaga").setup({
            -- 诊断增强
            diagnostic = {
                show_code_action = true,
                show_source = true,
                jump_num_shortcut = true,
                max_width = 0.7,
                keys = {
                    exec_action = "<CR>",
                    quit = "q",
                    toggle_or_jump = "<Tab>"
                }
            },

            -- 代码操作增强
            code_action = {
                num_shortcut = true,
                extend_gitsigns = true,
                keys = {
                    quit = "q",
                    exec = "<CR>"
                }
            },

            -- 悬浮文档
            hover = {
                max_width = 0.9,
                open_link = "gx"
            },

            -- 智能灯泡提示
            --lightbulb = {
            --    enable = true,
            --    sign = "💡",
            --    virtual_text = true
            --}
        })
        end
    },

    -- 快捷键统一配置
    {
        "folke/which-key.nvim",
        event = "VeryLazy",
        init = function()
        -- LSP 基础快捷键
        vim.keymap.set("n", "gr", vim.lsp.buf.references, { desc = "查看引用" })

        -- Lspsaga 增强快捷键
        vim.keymap.set("n", "K", "<cmd>Lspsaga hover_doc<CR>", { desc = "悬浮文档" })
        vim.keymap.set("n", "<leader>cd", "<cmd>Lspsaga show_line_diagnostics<CR>", { desc = "行诊断" })

        end
    }
}
